import { promises } from 'dns'

import { ajax } from '@/utils'

import {
  addDivisionItem,
  addHeadOfficeItem,
  ApplyInfo,
  ChooseDivisionItem,
  editHeadOffice,
  editListItem,
  ExpressInfo,
  getList,
  importOrders,
  PrincipalName,
  RejectInfo,
  ServiceData,
  ServiceDataConfig,
  WithdrawDetail,
  WithdrawRejectReq
} from './riverTypes'

export default {
  /** 查询 */
  getSupplierList(data: any): Promise<any> {
    return ajax.post('/yswy-zy-activity/manage/serviceProvider/list', data)
  },
  /** 驳回 */
  reject(data: RejectInfo): Promise<any> {
    return ajax.post('/yswy-zy-activity/manage/serviceProvider/reject', data)
  },

  /**服务商通过审核 */
  approve(id: any): Promise<any> {
    return ajax.get(`/yswy-zy-activity/manage/serviceProvider/approve/${id}`)
  },
  //**总裁通过审核 */
  presidentApprove(id: any): Promise<any> {
    return ajax.get(
      `/yswy-zy-activity/manage/serviceProvider/president/approve/${id}`
    )
  },
  /**详情 */
  getDetail(id: any): Promise<ApplyInfo> {
    return ajax.get(`/yswy-zy-activity/manage/serviceProvider/detail/${id}`)
  },

  /**--财务管理相关开始-- */
  //提现列表
  getWithdrawList(data: any): Promise<any> {
    return ajax.post('/yswy-zy-activity/withdrawManage/list', data)
  },
  //提现历史记录列表
  getWithdrawHistoryList(id: any): Promise<any> {
    return ajax.get(`/yswy-zy-activity/withdrawManage/history/${id}`)
  },
  //导出Excel
  exportExcel(data) {
    return ajax.post('/yswy-zy-activity/withdrawManage/export', data, {
      withResponse: true,
      responseType: 'blob'
    })
  },
  //批量审核通过
  batchAgree(ids: number[]) {
    return ajax.post('/yswy-zy-activity/withdrawManage/checkAgree', { ids })
  },
  //批量确认打款
  batchPayConfirm(ids: number[]) {
    return ajax.post('/yswy-zy-activity/withdrawManage/batchConfirm', { ids })
  },
  //批量下载发票
  batchDownInvoice(ids: number[]) {
    return ajax.post(
      '/yswy-zy-activity/withdrawManage/batchDownInvoice',
      {
        ids
      },
      {
        withResponse: true,
        responseType: 'blob'
      }
    )
  },
  //批量签收发票
  batchSignReceive(ids: number[]) {
    return ajax.post('/yswy-zy-activity/withdrawManage/batchSignReceive', {
      ids
    })
  },
  //保存打款状态
  savePayStatus(id: any, isPay: any) {
    return ajax.post(`/yswy-zy-activity/withdrawManage/changePay/${id}`, {
      id,
      isPay
    })
  },
  //历史记录列表
  getHistoryList(id: any): Promise<any> {
    return ajax.get(`/yswy-zy-activity/withdrawManage/history/${id}`)
  },
  // 备注
  remark(id: any, comments: any): Promise<any> {
    return ajax.post('/yswy-zy-activity/withdrawManage/comments', {
      id,
      comments
    })
  },
  //提现记录详情
  getWidthdrawDetail(id: any): Promise<WithdrawDetail> {
    return ajax.get(`/yswy-zy-activity/withdrawManage/detail/${id}`)
  },
  //历史记录详情
  getHistoryDetail(id: any): Promise<WithdrawDetail> {
    return ajax.get(`/yswy-zy-activity/withdrawManage/historyDetail/${id}`)
  },

  //提现拒绝
  widthdrawReject(data: WithdrawRejectReq): Promise<any> {
    return ajax.post(`/yswy-zy-activity/withdrawManage/reject`, data)
  },

  //下载结算单
  dowanloadReceipt(id: any): Promise<any> {
    return ajax.get(`/yswy-zy-activity/withdrawManage/downSettle/${id}`, {
      withResponse: true,
      responseType: 'blob'
    })
  },

  //重新生成结算单
  recreateReceipt(id: any) {
    return ajax.post(`/yswy-zy-activity/withdrawManage/resettle/${id}`)
  },
  //强制审核完成
  forceCompleteReceipt(id: any) {
    return ajax.get(`/yswy-zy-activity/withdrawManage/forceComplete/${id}`)
  },

  //获取发票图片列表
  getBillImageList(id: any): Promise<any> {
    return ajax.get(`/yswy-zy-activity/withdrawManage/rejectInvoices/${id}`)
  },
  /**--财务管理相关结束-- */

  //获取位置信息配置
  getAddressConfig(): Promise<ExpressInfo> {
    return ajax.get(`/yswy-zy-activity/xhConfig/address`)
  },

  //设置位置信息
  updateAddressConfig(data: ExpressInfo): Promise<any> {
    return ajax.post(`/yswy-zy-activity/xhConfig/save`, data)
  },

  //查询服务商收益配置信息
  getConfigurationiOInformation(): Promise<ServiceData> {
    return ajax.post(`/yswy-zy-activity/salesCompanyConfig/selectserverinfo`)
  },
  //修改服务商收益配置信息
  editConfigurationiOInformation(data: ServiceData): Promise<ServiceData> {
    return ajax.post(
      `/yswy-zy-activity/salesCompanyConfig/updateserverinfo`,
      data
    )
  },
  /////////////////////////////////////////////
  //查询服务商费用结算明细配置
  getSelectConfigConfiguration(): Promise<ServiceDataConfig> {
    return ajax.post(
      `/yswy-zy-activity/serviceFeeSettlement/config/select/config`
    )
  },
  //修改服务商收益配置信息
  editGetSelectConfigConfiguration(
    item: ServiceDataConfig
  ): Promise<ServiceDataConfig> {
    return ajax.post(
      `/yswy-zy-activity/serviceFeeSettlement/config/update/config`,
      item
    )
  },
  // 上传回单
  uploadReceipt(data: any): Promise<any> {
    return ajax.post('/yswy-zy-activity/xhReceipt/upload', data)
  },
  // 回单列表
  getReceiptList(data: any): Promise<any> {
    return ajax.post('/yswy-zy-activity/xhReceipt/list', data)
  },
  // 回单明细列表
  getReceiptDetailList(data: any): Promise<any> {
    return ajax.post('/yswy-zy-activity/xhReceipt/detailList', data)
  },
  // 新增回单详情
  getReceiptSubDetailList(serialNo: any): Promise<any> {
    return ajax.get(`/yswy-zy-activity/xhReceipt/detail/${serialNo}`)
  },
  // 驳回审核通过
  rejectReview(data: any): Promise<any> {
    return ajax.post(`/yswy-zy-activity/manage/serviceProvider/reject`, data)
  },
  // 总裁驳回
  presidentRejectReview(data: any): Promise<any> {
    return ajax.post(
      `/yswy-zy-activity/manage/serviceProvider/president/reject`,
      data
    )
  },
  //查询事业部
  getDivisionList(data: any): Promise<getList> {
    return ajax.post(
      '/yswy-zy-activity/businessDivision/management/selectAllBusinessDivisionInfo',
      data
    )
  },
  // 编辑查询
  editDivisionList(id: any): Promise<ChooseDivisionItem> {
    return ajax.post(
      `/yswy-zy-activity/businessDivision/management/editselectinfo/${id}`
    )
  },
  //编辑
  editList(data: any): Promise<editListItem> {
    return ajax.post(
      `/yswy-zy-activity/businessDivision/management/choose/editBusinessDivisioninfo`,
      data
    )
  },
  //新增事业部
  addDivisionList(data: any): Promise<addDivisionItem> {
    return ajax.post(
      '/yswy-zy-activity/businessDivision/management/add/BusinessDivision',
      data
    )
  },
  //事业部负责人查询
  divisionPrincipalName(data: any): Promise<any> {
    return ajax.post(
      '/yswy-zy-activity/businessDivision/management/choose/businessDivisionPrincipalName',
      data
    )
  },
  // 选择下辖群号
  selectGroupNumber(): Promise<any> {
    return ajax.post(
      '/yswy-zy-activity/businessDivision/management/choose/subordinateGroupNumber'
    )
  },
  //查询总部
  selectHeadOfficeInfoList(data: any): Promise<any> {
    return ajax.post(
      '/yswy-zy-activity/headOfficeInfo/management/selectHeadOfficeInfo',
      data
    )
  },
  //新增总部
  addHeadOfficeList(data: any): Promise<addHeadOfficeItem> {
    return ajax.post(
      '/yswy-zy-activity/headOfficeInfo/management/addHeadOffice',
      data
    )
  },
  //总部负责人查询
  SearchHeadOfficeList(data: any): Promise<any> {
    return ajax.post(
      '/yswy-zy-activity/headOfficeInfo/management/choose/headOffice',
      data
    )
  },
  //总部下属事业部
  selectBusinessDivision(data: any): Promise<any> {
    return ajax.post(
      '/yswy-zy-activity/headOfficeInfo/management/choose/selectNewSubordinateBusinessDivision',
      data
    )
  },
  //编辑总部查询
  editHeadOfficeInfoList(id: any): Promise<any> {
    return ajax.post(
      `/yswy-zy-activity/headOfficeInfo/management/editHeadOfficeInfo/${id}`
    )
  },
  //编辑总部
  editHeadOfficeList(data: any): Promise<editHeadOffice> {
    return ajax.post(
      '/yswy-zy-activity/headOfficeInfo/management/editHeadOffice',
      data
    )
  },
  //查询导入线下订单
  queryOfflineOrder(data: any): Promise<any> {
    return ajax.post(
      '/yswy-zy-activity/offlineOrder/selectImportOfflineOrder',
      data
    )
  },
  //批量删除
  batchDelete(data: any): Promise<any> {
    return ajax.post(
      '/yswy-zy-activity/offlineOrder/batchDelImportOfflineOrder',
      data
    )
  },
  //单个删除
  DeleteOrder(idImportOfflineOrder: any): Promise<any> {
    return ajax.post(
      `/yswy-zy-activity/offlineOrder/delImportOfflineOrder/${idImportOfflineOrder}`
    )
  },
  //导入订单
  importOfflineOrder(data): Promise<any> {
    return ajax.post('/yswy-zy-activity/offlineOrder/import', data, {
      timeout: 600_000
    })
  },
  //上传合同
  uploadContract(data): Promise<any> {
    return ajax.post(
      '/yswy-zy-activity/manage/serviceProvider/upload/contract',
      data
    )
  },
  //配置页操作日志
  getConfigurationLog(data: any): Promise<any> {
    return ajax.post(`/yswy-zy-activity/updateLog/config/list`, data)
  },
  //基本资料页操作日志
  getBasicLog(data: any): Promise<any> {
    return ajax.post(`/yswy-zy-activity/updateLog/member/list`, data)
  },
  //销售公司操作日志
  getSalesCompanycLog(data: any): Promise<any> {
    return ajax.post(`/yswy-zy-activity/updateLog/saleCompany/list`, data)
  },
  // 服务商审核操作日志
  getServicerUpdateLog(data: any): Promise<any> {
    return ajax.post(
      `/yswy-zy-activity/updateLog/select/serviceProviderUpdateLog`,
      data
    )
  }
}
